/**
 * 
 */
package org.youisoft.summer.evaluator.function.core;

import org.youisoft.summer.evaluator.InvokeException;
import org.youisoft.summer.evaluator.UnitEnum;
import org.youisoft.summer.evaluator.context.CalContext;
import org.youisoft.summer.evaluator.function.AbstractFunction;
import org.youisoft.summer.evaluator.operator.Operator;
import org.youisoft.summer.evaluator.operator.base.ClosureOperator;
import org.youisoft.summer.evaluator.unit.Bracket;

/**
 * @author zijiang.jl
 *
 */
public class BracketFunction extends AbstractFunction{
	
	@Override
	public String getName() {
		return Bracket.class.getName();
	}
	
	
	

	@Override
	protected boolean checkBracketOperator(int index, Operator<?> operator) {
		return true;
	}




	@Override
	public UnitEnum getType() {
		return UnitEnum.bracket;
	}




	@Override
	public <C, R, P> Operator<?> doBracketInvoke(CalContext<C, R, P> context,
			Operator<?>... operator) throws InvokeException {
		for(Operator<?> op:operator){
			if(op instanceof ClosureOperator){
				ClosureOperator co=ClosureOperator.class.cast(op);
				co.execute(context);
			}
			
		}
		return Operator.nullInstance;
	}

	@Override
	public boolean addendumOperator() {
		return true;
	}
	
	
}
